#pragma once

namespace DirectUI
{
	class CUIPageLoader 
		: public CUINoAggregateObjectImplHelper<IUIPageLoader, CUIPageLoader, IUIPageLoader>
	{
		DECLARE_CLASS(CUIPageLoader, PageLoader)
	public:
		CUIPageLoader(void);
		virtual ~CUIPageLoader(void);

		virtual BOOL	LoadPage(LPCTSTR lpPageXml, IUIPage** lppPage);

	private:
		BOOL LoadUIElement(xml_node& node, IUIObject** lppObj, IUIElement* lpTopPage);
		BOOL LoadUIElementControlTemplate(xml_node& node, IUIObject* lpObj, LPCTSTR lpszNodeName, IUIElement* lpTopPage);
		BOOL LoadUIElementResources(xml_node& node, IUIObject* lpObj, LPCTSTR lpszNodeName);
		BOOL LoadStoryboard(xml_node& node, IUIObject** lppObj);
		BOOL LoadUIElementVisualStateManager(xml_node& node, std::map<CString, CUIObjectPtr<IUIVisualStateGroup>>& vVisualStateGroups);
		BOOL LoadStoryVisualStateGroup(xml_node& node, IUIObject** lppObj);
		BOOL LoadStoryVisualState(xml_node& node, IUIObject** lppObj);
		

		BOOL CreatePageCoreWindow(IUIElement* lpPage);

	private:
		CUIObjectPtr<IUICore>			m_spCore;
		CUIObjectPtr<IUIObjectFactory>	m_spUIObjectFactory;
	};
};